//
//  ViewController.swift
//  CNMTools
//
//  Created by StephentTom on 03/02/2022.
//  Copyright (c) 2022 StephentTom. All rights reserved.
//

import UIKit
import CNMTools
import SnapKit
    
class ViewController: UIViewController {
    private lazy var topSafeView0: UIView = {
        let view = UIView()
        return view
    }()
    private lazy var topSafeView1: UIView = {
        let view = UIView()
        return view
    }()
    private lazy var topSafeView2: UIView = {
        let view = UIView()
        return view
    }()
    
    private lazy var showView = UIView(frame: CGRect(x: 20, y: (self.view.bounds.height - 219)*0.5, width: 360 - 40, height: 219))
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        
//        let attri = NSAttributedString(string: "其他手机号码登录", attributes: [
//            NSAttributedString.Key.foregroundColor : UIColor.yellow,
//            NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue,
//            NSAttributedString.Key.underlineColor: UIColor.systemPink,
//            NSAttributedString.Key.font: UIFont.systemFont(ofSize: 20, weight: .bold)
//        ])
        
        let button = UIButton(type: .system)
        button.cnm_setUnderLine(title: "其他手机号码登录", andTitleColor: .brown, andFont: UIFont.systemFont(ofSize: 20, weight: .bold), andUnderlineColor: .purple)
        button.addTarget(self, action: #selector(testAction), for: .touchUpInside)
        
        self.view.addSubview(button)
        button.frame = CGRect(x: 20, y: 100, width: 180, height: 35)
        
        let testString = "/var/mobile/Containers/Data/Application/543BEDD2-CD04-4761-BEBB-2649407179C3/Documents/com_tencent_imsdk_data/images/1400637819_146344_image_1649666597_853"
        let rs = testString.cnm_subStringFrom(index: "/var/mobile/Containers/Data/Application/543BEDD2-CD04-4761-BEBB-2649407179C3/Documents/com_tencent_imsdk_data/images/".count)
        print("结果：\(rs)")
        
        
        let iamge = UIImage(nameInBundle: "dl_logo", bundleName: "Common", targetClass: ViewController.self)
        let icon = UIImageView(image: iamge)
        icon.frame = CGRect(x: 120, y: 200, width: 25, height: 25)
        self.view.addSubview(icon)
        
        view.addSubview(topSafeView0)
        view.addSubview(topSafeView1)
        view.addSubview(topSafeView2)
        
        topSafeView0.backgroundColor = cnm_randomColor()
        topSafeView1.backgroundColor = cnm_randomColor()
        topSafeView2.backgroundColor = cnm_randomColor()
        
        topSafeView0.frame = CGRect(x: 0, y: 350, width: view.bounds.width, height: 44)
        topSafeView1.frame = CGRect(x: 0, y: 350 + 44, width: view.bounds.width, height: 44)
        topSafeView2.frame = CGRect(x: 0, y: 350 + 44 + 44, width: view.bounds.width, height: 44)
        
        
        let cityButton = UIButton(type: .system)
        cityButton.setTitle("San FranciscoSan", for: .normal)
        cityButton.setImage(UIImage(named: "pub_city_change"), for: .normal)
        
        view.addSubview(cityButton)
        cityButton.snp.makeConstraints { make in
            make.left.equalTo(20)
            make.bottom.equalTo(-30)
            make.height.equalTo(30)
        }
        cityButton.cnm_layout(with: .right, space: 5)
        
        print(UIScreen.cnm_safeAreaInsets)
        print(UIScreen.cnm_safeAreaBottom)
        print(cnm_isFullScreen)
    }
    
    @objc func testAction() {
        showView.backgroundColor = .systemGreen
        CNMMaskView.shared.show(childView: showView)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

